﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;

using LogCS;

namespace AZPEP_SysRi_Tool
{
    public class LogProtocol
    {
        /// <summary>
        /// 启动Log服务，在(程序运行目录)\\log中创建日志文件
        /// </summary>
        /// <param name="Title">日志标题</param>
        /// <returns>成功返回true，失败返回false</returns>
        public static bool StartLogServices(string Title)
        {
            return Log.LogCsStartService(Title);
        }

        /// <summary>
        /// 启动Log服务，但写入由用户自行创建的Log文件中
        /// </summary>
        /// <param name="LogFilePath">Log文件的绝对路径</param>
        /// <param name="Title">日志标题</param>
        /// <returns>成功返回true，失败返回false</returns>
        public static bool StartLogServicesEx(
            string LogFilePath,
            string Title
            )
        {
            return Log.LogCsStartServiceEx(LogFilePath,Title);
        }

        /// <summary>
        /// 停止Log服务
        /// </summary>
        public static void StopLogService()
        {
            Log.LogCsStopService();
        }

        /// <summary>
        /// 检查Log服务是否开启
        /// </summary>
        /// <returns>开启返回true，未开启返回false</returns>
        public static bool IsLogServiceEnable()
        {
            return Log.LogCsCheckServiceOpenStatus();
        }

        /// <summary>
        /// 获取Log文件按的绝对路径
        /// </summary>
        /// <returns>返回Log文件的路径，若创建log文件失败或未开启log服务，返回""</returns>
        public static string GetLogFilePath()
        {
            return Log.LogCsGetFileFullPath();
        }

        /// <summary>
        /// 写入Log
        /// </summary>
        public static class WriteLog
        {
            /// <summary>
            /// 打印Debug信息，注意：未启动Debug会自动忽略本函数
            /// </summary>
            /// <param name="message">信息</param>
            public static void Debug(string message)
            {
#if DEBUG
                Log.LogCsDebug(message);
#endif
            }

            /// <summary>
            /// 打印普通信息
            /// </summary>
            /// <param name="message">信息</param>
            public static void Info(string message)
            {
                Log.LogCsInfo(message);
            }

            /// <summary>
            /// 打印警告信息
            /// </summary>
            /// <param name="message">信息</param>
            public static void Warning(string message)
            {
                Log.LogCsWarning(message);
            }

            /// <summary>
            /// 打印错误信息
            /// </summary>
            /// <param name="message">信息</param>
            public static void Error(string message)
            {
                Log.LogCsError(message);
            }
        }
    }
}
